<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.18"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>HElib: /HElib/include/helib/replicate.h Source File</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
		<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;1,700&family=Merriweather&family=Merriweather+Sans&family=Open+Sans&family=Poppins:ital@1&family=Roboto:ital,wght@0,400;1,300;1,900&display=swap" rel="stylesheet"> 
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body style="font-family: 'Merriweather', serif;">
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand">HElib Implementing Homomorphic Encryption</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_d0c4ae63660968bf6b1c77a1e8aecf95.html">helib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">replicate.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="replicate_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* Copyright (C) 2012-2020 IBM Corp.</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This program is Licensed under the Apache License, Version 2.0</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * (the &quot;License&quot;); you may not use this file except in compliance</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * with the License. You may obtain a copy of the License at</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *   http://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * See the License for the specific language governing permissions and</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * limitations under the License. See accompanying LICENSE file.</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#ifndef HELIB_REPLICATE_H</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#define HELIB_REPLICATE_H</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_encrypted_array_8h.html">helib/EncryptedArray.h</a>&gt;</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_ptxt_8h.html">helib/Ptxt.h</a>&gt;</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160; </div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacehelib.html">helib</a> {</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment">// set to true to see some more info...</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;NTL_THREAD_LOCAL</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="namespacehelib.html#a47f0fb8de69aa81c6224003a79011ed3">replicateVerboseFlag</a>;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">class </span>RepAux; <span class="comment">// forward declarations</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="keyword">class </span>RepAuxDim;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a28bebe2d214c86938103f34adecb7ff3">replicate</a>(<span class="keyword">const</span> EncryptedArray&amp; ea, Ctxt&amp; ctx, <span class="keywordtype">long</span> pos);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#adb07910b30bab32f4ebf91af705e3c6d">replicate0</a>(<span class="keyword">const</span> EncryptedArray&amp; ea, Ctxt&amp; ctxt, <span class="keywordtype">long</span> pos);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; </div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="classhelib_1_1_replicate_handler.html">   55</a></span>&#160;<span class="keyword">class </span><a class="code" href="classhelib_1_1_replicate_handler.html">ReplicateHandler</a></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;{</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="classhelib_1_1_replicate_handler.html#ab1948419f4d93c8de6afd3eb43d707d5">   58</a></span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classhelib_1_1_replicate_handler.html#ab1948419f4d93c8de6afd3eb43d707d5">handle</a>(<span class="keyword">const</span> <a class="code" href="classhelib_1_1_ctxt.html">Ctxt</a>&amp; ctxt) = 0;</div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="classhelib_1_1_replicate_handler.html#a73529e97459544eec2f29b755737cfb1">   59</a></span>&#160;  <span class="keyword">virtual</span> <a class="code" href="classhelib_1_1_replicate_handler.html#a73529e97459544eec2f29b755737cfb1">~ReplicateHandler</a>() {}</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="comment">// The earlyStop call can be used to quit the replication mid-way, leaving</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  <span class="comment">// a ciphertext with (e.g.) two different entries, each replicated n/2 times</span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="comment">// FIXME: Why does this function have arguments? Maybe remove them and then</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="comment">// remove the pragma.</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="preprocessor">#pragma GCC diagnostic push</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="preprocessor">#pragma GCC diagnostic ignored &quot;-Wunused-parameter&quot;</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="classhelib_1_1_replicate_handler.html#a75d551cd8259d718f6507f381e218dbd">   67</a></span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classhelib_1_1_replicate_handler.html#a75d551cd8259d718f6507f381e218dbd">earlyStop</a>(<span class="keywordtype">long</span> d, <span class="keywordtype">long</span> k, <span class="keywordtype">long</span> prodDim) { <span class="keywordflow">return</span> <span class="keyword">false</span>; }</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="preprocessor">#pragma GCC diagnostic pop</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;};</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="comment">// Applications will derive from this class a handler that actually</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="comment">// does something with the replicated ciphertexts. But it can be used</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="comment">// by itself as a do-nothing replicator for debugging, or to calculate</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="comment">// the required automorphisms (see automorphVals in numbTh.h)</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a55f84fcea62365a27445739f444d81db">replicateAll</a>(<span class="keyword">const</span> EncryptedArray&amp; ea,</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;                  <span class="keyword">const</span> Ctxt&amp; ctxt,</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;                  ReplicateHandler* handler,</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;                  <span class="keywordtype">long</span> recBound = 64,</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;                  RepAuxDim* repAuxPtr = <span class="keyword">nullptr</span>);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a55f84fcea62365a27445739f444d81db">replicateAll</a>(std::vector&lt;Ctxt&gt;&amp; v,</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                  <span class="keyword">const</span> EncryptedArray&amp; ea,</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                  <span class="keyword">const</span> Ctxt&amp; ctxt,</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                  <span class="keywordtype">long</span> recBound = 64,</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;                  RepAuxDim* repAuxPtr = <span class="keyword">nullptr</span>);</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Scheme&gt;</div>
<div class="line"><a name="l00115"></a><span class="lineno"><a class="line" href="namespacehelib.html#a80787c8857d1d8b8b4fad63f11201626">  115</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a55f84fcea62365a27445739f444d81db">replicateAll</a>(std::vector&lt;<a class="code" href="classhelib_1_1_ptxt.html">Ptxt&lt;Scheme&gt;</a>&gt;&amp; v,</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;                  <span class="keyword">const</span> <a class="code" href="classhelib_1_1_encrypted_array.html">EncryptedArray</a>&amp;,</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;                  <span class="keyword">const</span> <a class="code" href="classhelib_1_1_ptxt.html">Ptxt&lt;Scheme&gt;</a>&amp; ptxt)</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;{</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;  v = ptxt.<a class="code" href="classhelib_1_1_ptxt.html#a7f5ad875da05a1562e319f3943892c67">replicateAll</a>();</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;}</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#ae12fb4b6143d8e2cb6a5dbf36922fbe7">replicateAllOrig</a>(<span class="keyword">const</span> EncryptedArray&amp; ea,</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;                      <span class="keyword">const</span> Ctxt&amp; ctxt,</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;                      ReplicateHandler* handler,</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;                      RepAux* repAuxPtr = <span class="keyword">nullptr</span>);</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160; </div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a28bebe2d214c86938103f34adecb7ff3">replicate</a>(<span class="keyword">const</span> EncryptedArray&amp; ea, PlaintextArray&amp; pa, <span class="keywordtype">long</span> i);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160; </div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Scheme&gt;</div>
<div class="line"><a name="l00140"></a><span class="lineno"><a class="line" href="namespacehelib.html#ae14f023af8c881464a3dbaf01b18d7da">  140</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a28bebe2d214c86938103f34adecb7ff3">replicate</a>(<span class="keyword">const</span> <a class="code" href="classhelib_1_1_encrypted_array.html">EncryptedArray</a>&amp;, <a class="code" href="classhelib_1_1_ptxt.html">Ptxt&lt;Scheme&gt;</a>&amp; ptxt, <span class="keywordtype">long</span> i)</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;{</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  ptxt.<a class="code" href="classhelib_1_1_ptxt.html#ad1459a4416bb38e0863e220e5cfe6ff9">replicate</a>(i);</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;}</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160; </div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="comment">// Structures to keep tables of masking constants that are used in</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="comment">// replication. A calling application can either supply this structure</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="comment">// itself (if it is going to replicate the same tables in multiple</span></div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;<span class="comment">// replicate operations), or is cal let the replication code use its</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="comment">// own tables (in which case they are destroyed at the end of the</span></div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;<span class="comment">// replication process)</span></div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160; </div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;<span class="keyword">class </span>RepAux</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;{ <span class="comment">// one table for the whole thing</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  std::vector&lt;copied_ptr&lt;DoubleCRT&gt;&gt; _tab;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160; </div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  copied_ptr&lt;DoubleCRT&gt;&amp; tab(<span class="keywordtype">long</span> i)</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  {</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <span class="keywordflow">if</span> (i &gt;= <a class="code" href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">lsize</a>(_tab))</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;      _tab.resize(i + 1);</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="keywordflow">return</span> _tab[i];</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;  }</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;};</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;<span class="keyword">class </span>RepAuxDim</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;{ <span class="comment">// two tables per dimension</span></div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  std::vector&lt;std::vector&lt;copied_ptr&lt;DoubleCRT&gt;&gt;&gt; _tab, _tab1;</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160; </div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;  copied_ptr&lt;DoubleCRT&gt;&amp; tab(<span class="keywordtype">long</span> d, <span class="keywordtype">long</span> i)</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;  {</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    <span class="keywordflow">if</span> (d &gt;= <a class="code" href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">lsize</a>(_tab))</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;      _tab.resize(d + 1);</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="keywordflow">if</span> (i &gt;= <a class="code" href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">lsize</a>(_tab[d]))</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;      _tab[d].resize(i + 1);</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    <span class="keywordflow">return</span> _tab[d][i];</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  }</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160; </div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;  copied_ptr&lt;DoubleCRT&gt;&amp; tab1(<span class="keywordtype">long</span> d, <span class="keywordtype">long</span> i)</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  {</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    <span class="keywordflow">if</span> (d &gt;= <a class="code" href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">lsize</a>(_tab1))</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;      _tab1.resize(d + 1);</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    <span class="keywordflow">if</span> (i &gt;= <a class="code" href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">lsize</a>(_tab1[d]))</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;      _tab1[d].resize(i + 1);</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    <span class="keywordflow">return</span> _tab1[d][i];</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;  }</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;};</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;} <span class="comment">// namespace helib</span></div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160; </div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;<span class="preprocessor">#endif // ifndef HELIB_REPLICATE_H</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclasshelib_1_1_ptxt_html"><div class="ttname"><a href="classhelib_1_1_ptxt.html">helib::Ptxt</a></div><div class="ttdoc">An object that mimics the functionality of the Ctxt object, and acts as a convenient entry point for ...</div><div class="ttdef"><b>Definition:</b> Ctxt.h:66</div></div>
<div class="ttc" id="anamespacehelib_html_ae8f65ef133cee27ad846423d012d5487"><div class="ttname"><a href="namespacehelib.html#ae8f65ef133cee27ad846423d012d5487">helib::lsize</a></div><div class="ttdeci">long lsize(const std::vector&lt; T &gt; &amp;v)</div><div class="ttdoc">Size of STL vector as a long (rather than unsigned long)</div><div class="ttdef"><b>Definition:</b> NumbTh.h:652</div></div>
<div class="ttc" id="aclasshelib_1_1_replicate_handler_html_a75d551cd8259d718f6507f381e218dbd"><div class="ttname"><a href="classhelib_1_1_replicate_handler.html#a75d551cd8259d718f6507f381e218dbd">helib::ReplicateHandler::earlyStop</a></div><div class="ttdeci">virtual bool earlyStop(long d, long k, long prodDim)</div><div class="ttdef"><b>Definition:</b> replicate.h:67</div></div>
<div class="ttc" id="aclasshelib_1_1_replicate_handler_html_ab1948419f4d93c8de6afd3eb43d707d5"><div class="ttname"><a href="classhelib_1_1_replicate_handler.html#ab1948419f4d93c8de6afd3eb43d707d5">helib::ReplicateHandler::handle</a></div><div class="ttdeci">virtual void handle(const Ctxt &amp;ctxt)=0</div></div>
<div class="ttc" id="aclasshelib_1_1_replicate_handler_html_a73529e97459544eec2f29b755737cfb1"><div class="ttname"><a href="classhelib_1_1_replicate_handler.html#a73529e97459544eec2f29b755737cfb1">helib::ReplicateHandler::~ReplicateHandler</a></div><div class="ttdeci">virtual ~ReplicateHandler()</div><div class="ttdef"><b>Definition:</b> replicate.h:59</div></div>
<div class="ttc" id="aclasshelib_1_1_encrypted_array_html"><div class="ttname"><a href="classhelib_1_1_encrypted_array.html">helib::EncryptedArray</a></div><div class="ttdoc">A simple wrapper for a smart pointer to an EncryptedArrayBase. This is the interface that higher-leve...</div><div class="ttdef"><b>Definition:</b> EncryptedArray.h:1237</div></div>
<div class="ttc" id="aclasshelib_1_1_ptxt_html_a7f5ad875da05a1562e319f3943892c67"><div class="ttname"><a href="classhelib_1_1_ptxt.html#a7f5ad875da05a1562e319f3943892c67">helib::Ptxt::replicateAll</a></div><div class="ttdeci">std::vector&lt; Ptxt&lt; Scheme &gt; &gt; replicateAll() const</div><div class="ttdoc">Generate a vector of plaintexts with each slot replicated in each plaintext.</div><div class="ttdef"><b>Definition:</b> Ptxt.cpp:706</div></div>
<div class="ttc" id="anamespacehelib_html_ae12fb4b6143d8e2cb6a5dbf36922fbe7"><div class="ttname"><a href="namespacehelib.html#ae12fb4b6143d8e2cb6a5dbf36922fbe7">helib::replicateAllOrig</a></div><div class="ttdeci">void replicateAllOrig(const EncryptedArray &amp;ea, const Ctxt &amp;ctxt, ReplicateHandler *handler, RepAux *repAuxPtr=nullptr)</div><div class="ttdef"><b>Definition:</b> replicate.cpp:225</div></div>
<div class="ttc" id="a_ptxt_8h_html"><div class="ttname"><a href="_ptxt_8h.html">Ptxt.h</a></div><div class="ttdoc">Plaintext object parameterised on CKKS and BGV schemes. Also contains definition of CKKS and BGV stru...</div></div>
<div class="ttc" id="anamespacehelib_html_a28bebe2d214c86938103f34adecb7ff3"><div class="ttname"><a href="namespacehelib.html#a28bebe2d214c86938103f34adecb7ff3">helib::replicate</a></div><div class="ttdeci">void replicate(const EncryptedArray &amp;ea, Ctxt &amp;ctx, long pos)</div><div class="ttdoc">The value in slot #pos is replicated in all other slots. On an n-slot ciphertext, this algorithm perf...</div><div class="ttdef"><b>Definition:</b> replicate.cpp:26</div></div>
<div class="ttc" id="a_encrypted_array_8h_html"><div class="ttname"><a href="_encrypted_array_8h.html">EncryptedArray.h</a></div><div class="ttdoc">Data-movement operations on encrypted arrays of slots.</div></div>
<div class="ttc" id="anamespacehelib_html_adb07910b30bab32f4ebf91af705e3c6d"><div class="ttname"><a href="namespacehelib.html#adb07910b30bab32f4ebf91af705e3c6d">helib::replicate0</a></div><div class="ttdeci">void replicate0(const EncryptedArray &amp;ea, Ctxt &amp;ctxt, long pos)</div><div class="ttdoc">A lower-level routine. Same as replicate, but assumes all slots are zero except slot #pos.</div><div class="ttdef"><b>Definition:</b> replicate.cpp:43</div></div>
<div class="ttc" id="anamespacehelib_html"><div class="ttname"><a href="namespacehelib.html">helib</a></div><div class="ttdef"><b>Definition:</b> apiAttributes.h:21</div></div>
<div class="ttc" id="anamespacehelib_html_a47f0fb8de69aa81c6224003a79011ed3"><div class="ttname"><a href="namespacehelib.html#a47f0fb8de69aa81c6224003a79011ed3">helib::replicateVerboseFlag</a></div><div class="ttdeci">NTL_THREAD_LOCAL bool replicateVerboseFlag</div><div class="ttdef"><b>Definition:</b> replicate.cpp:20</div></div>
<div class="ttc" id="aclasshelib_1_1_ctxt_html"><div class="ttname"><a href="classhelib_1_1_ctxt.html">helib::Ctxt</a></div><div class="ttdoc">A Ctxt object holds a single ciphertext.</div><div class="ttdef"><b>Definition:</b> Ctxt.h:270</div></div>
<div class="ttc" id="aclasshelib_1_1_replicate_handler_html"><div class="ttname"><a href="classhelib_1_1_replicate_handler.html">helib::ReplicateHandler</a></div><div class="ttdoc">An abstract class to handle call-backs to get the output of replicate.</div><div class="ttdef"><b>Definition:</b> replicate.h:56</div></div>
<div class="ttc" id="anamespacehelib_html_a55f84fcea62365a27445739f444d81db"><div class="ttname"><a href="namespacehelib.html#a55f84fcea62365a27445739f444d81db">helib::replicateAll</a></div><div class="ttdeci">void replicateAll(const EncryptedArray &amp;ea, const Ctxt &amp;ctxt, ReplicateHandler *handler, long recBound=64, RepAuxDim *repAuxPtr=nullptr)</div><div class="ttdef"><b>Definition:</b> replicate.cpp:666</div></div>
<div class="ttc" id="aclasshelib_1_1_ptxt_html_ad1459a4416bb38e0863e220e5cfe6ff9"><div class="ttname"><a href="classhelib_1_1_ptxt.html#ad1459a4416bb38e0863e220e5cfe6ff9">helib::Ptxt::replicate</a></div><div class="ttdeci">Ptxt&lt; Scheme &gt; &amp; replicate(long pos)</div><div class="ttdoc">Replicate single slot across all slots.</div><div class="ttdef"><b>Definition:</b> Ptxt.cpp:696</div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
        <script type="text/javascript" src="doxy-boot.js"></script>
</html>
